#include <iostream>
#include <vector>
#include <algorithm> //算法头文件

using namespace std;

int main() {
    //动态给数组赋值
    double nums[] = {1, 2, 3};
    for (int i = 0; i < 3; ++i) {
        cin >> nums[i];
        cout << nums[i];
    }



   /* vector<double> vecDouble = {98.5, 76.9, 43.6, 32.9};
    //向数组中插入数字
    vecDouble.push_back(100.8); //在数组尾部插入一个数字
    //遍历1
    for (int i = 0; i < vecDouble.size(); ++i) { //vecDouble.size()为返回vecDouble的大小
        cout << vecDouble[i] << endl;
    }
    //集合的通用遍历方法，使用迭代器 iterator
    vector<double>::iterator it; //得到迭代器-实际上是一个指针对象
    //从第一个元素开始迭代
    for(it = vecDouble.begin(); it != vecDouble.end(); ++it){
        cout << *it << endl;
    }
    //排序 打印出来的数字自动添加排序
    sort(vecDouble.begin(), vecDouble.end());//正序
    reverse(vecDouble.begin(), vecDouble.end());//逆序
    for(it = vecDouble.begin(); it != vecDouble.end(); ++it){
        cout << *it << endl;
    }*/




  /*  //使用二维数组
    string stu_names[] {"刘备", "关羽", "张飞"};
    string course_name[] {"语文", "数学", "英语"};
    const int ROW = 3;
    const int COL = 3;
    double scores[ROW][COL];
    for (int i = 0; i < ROW; ++i) { //外层循环控制学生
        for (int j = 0; j < COL; ++j) { //内层循环控制课程
            cout << stu_names[i] << "的" << course_name[j] << "成绩：";
            cin >> scores[i][j];
        }
    }
    //打印结果
    cout << "\t";
    for (int i = 0; i < COL; ++i) {
        cout << course_name[i] << "\t";
    }
    cout << endl;
    for (int i = 0; i < ROW; ++i) {
        cout << stu_names[i] << "\t";
        for (int j = 0; j < COL; ++j) {
            cout << scores[i][j] << "\t";
        }
        cout << endl;
    }*/


  /*  //实现数组元素的删除和插入
    double power[99];
    int powerCount = 0;
    double insertPower; //要插入的数值
    int insertIndex = 0;
    power[powerCount++] = 45771;
    power[powerCount++] = 42322;
    power[powerCount++] = 40907;
    power[powerCount++] = 40706;

    double temp;
    for (int i = 0; i < powerCount; ++i) {
        for (int j = 0; j < powerCount - i - 1; ++j) {
            if (power[j] < power[j + 1]){
                temp = power[j];
                power[j] = power[j + 1];
                power[j + 1] = temp;
            }
        }
    }
    cout << "排序后：" << endl;
    for (int i = 0; i < powerCount; ++i) {
        cout << power[i] << endl;
    }
    cout << endl;
    //插入
    cout << "请输入要插入的数字：" ;
    cin >> insertPower;
    insertIndex = powerCount;
    //1.找到第一个比插入数字大的位置insertIndex
    for (int i = 0; i < powerCount; ++i) {
        if (insertPower > power[i]){
            insertIndex = i;
            break;
        }
    }
    //2.从最后一个元素开始，将数字复制到后面一个元素中
    for (int i = powerCount - 1; i >= insertIndex; i--) {
        power[i + 1] = power[i];
    }
    //3.将要插入的数字赋值给下标为insertIndex的元素
    power[insertIndex] = insertPower;
    //4.将数组的总长度+1
    powerCount++;
    cout << "插入后：" << endl;
    for (int i = 0; i < powerCount; ++i) {
        cout << power[i] << endl;
    }
    //删除
    //1.找到要删除的元素下标
    double deletePower;
    int deleteIndex = INT_MIN;
    cout << "请输入要删除的数字：" ;
    cin >> deletePower;
    for (int i = 0; i < powerCount; ++i) {
        if (deletePower == power[i]){
            deleteIndex = i;
            break;
        }
    }
    //2.从找到的下标开始，后面一个元素复制给前面一个元素
    for (int i = deleteIndex; i < powerCount - 1; ++i) {
        power[i] = power[i + 1];
    }
    //3.总长度-1
    powerCount--;
    cout << "删除后：" << endl;
    for (int i = 0; i < powerCount; ++i) {
        cout << power[i] << '\t';
    }*/




   /* //选择排序
    int nums[] {8, 4, 2, 1, 23, 344, 12};
    int numsLen = sizeof (nums) / sizeof (int); //计算出数组的长度
    int min = nums[0];
    int minIndex = 0;
    int temp;
    for (int i = 0; i < numsLen; ++i) {
        min = nums[i];
        minIndex = i;
        for (int j = i + 1; j < numsLen; ++j) {
            if (nums[j] <min){
                min = nums[j];
                minIndex = j;
            }
        }
        //交换
        if (minIndex > i){
            temp = nums[minIndex];
            nums[minIndex] = nums[i];
            nums[i] = temp;
        }
    }
    cout << "排序后：" << endl;
    for (int i = 0; i < numsLen; ++i) {
        cout << nums[i] << endl;
    }
    //逆序
    for (int i = 0; i < numsLen / 2; ++i) {
        temp = nums[i];
        nums[i] = nums[numsLen - i - 1];
        nums[numsLen - i - 1] = temp;
    }
    cout << "逆序后：" << endl;
    for (int i = 0; i < numsLen; ++i) {
        cout << nums[i] << endl;
    }*/



  /*  //冒泡排序
    int temp;
    int nums [] = {15, 25, 90,  23, 9};
    int numsLen = sizeof (nums) / sizeof (int); //计算出数组的长度
    for (int i = 0; i < 5 - 1; i++){
        for(int j = 0; j < 4 - i; j++) {
            if(nums[j] < nums[j + 1]){
                //交换
                temp = nums[j];
                nums[j] = nums[j + 1];
                nums[j + 1] = temp;
            }
        }
    }
    cout << "排序后：" << endl;
    for (int i = 0; i < numsLen; ++i) {
        cout << nums[i] << endl;
    }*/



    /* int nums[] {8, 4, 2, 1, 23, 344, 12};
     int numsLen = sizeof (nums) / sizeof (int); //计算出数组的长度
     int sum = 0;
     for (int i = 0; i < numsLen; ++i) {
         cout << nums[i] << '\t';
     }
     cout << endl;
     //累加操作
     for (int i = 0; i < numsLen; ++i) {
         sum += nums[i];
     }
     cout << "数列的和为：" << sum << "\t平均值为：" << sum / numsLen << endl;
     //求数组中的最大值和最小值
     //假设第一个元素是最大值
     int max = nums[0];
     int maxIndex = 0; //最大值的下标
     for (int i = 1; i < numsLen; ++i) {
         if (nums[i] > max){
             max = nums[i];
             maxIndex = i;
         }
     }
     cout << "最大值是：" << max << '/' << nums[maxIndex] << endl;
     cout << "最大值的下标是：" << maxIndex << endl;

     //求出奇数个数和偶数个数
     int jCount = 0, oCount = 0;
     for (int i = 0; i < numsLen; ++i) {
         if (nums[i] % 2 == 0){
             oCount++;
         } else {
             jCount++;
         }
     }
     cout << "奇数个数是：" << jCount << '\t' << "偶数个数是：" << oCount << endl;

     //查找输入的数字在数组中的下标，没有找到的则下标为-1
     int searchNum;              //用户要查找的数字
     int searchIndex = INT_MIN; //用户查找数字的下标
     cout << "请输入要查找的数字：";
     cin >> searchNum;
     for (int i = 0; i < numsLen; ++i) {
         if (nums[i] == searchNum){
             searchIndex = i; //记录下查找的元素的下标
             break;
         }
     }
     if (searchIndex == INT_MIN){
         cout << "数组中没有这个数字" << endl;
     } else {
         cout << searchNum << "在数组中的下标为：" << searchIndex << endl;
     } */



  /*  //动态的从键盘录入信息并赋值
    const int N = 5;
    int num[N];
    for (int i = 0; i < N; ++i) {
        cout << "请输入第" << (i + 1) << " 个数组元素：";
        cin >> num[i];
    }
    for (int i = 0; i < N; ++i) {
        cout << num[i] << endl;
    }*/
    return 0;
}
